package Dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import Util.ConnectionUtil;
import model.Course;

public class CourseDao {

	public static ArrayList<Course> queryCourseList() {
		ArrayList<Course> courseList = new ArrayList<>();
		
		Connection connection=ConnectionUtil.getConnection();
		String sql= "select * from kc";
		try {
			Statement statement=connection.createStatement();
			ResultSet rs =statement.executeQuery(sql);
			while (rs.next()) {
				String course_id=rs.getString(1);
				String course_name=rs.getString(2);
				String course_teacher=rs.getString(3);
				
				Course course=new Course(course_id,course_name,course_teacher);
				courseList.add(course);
			}
		} catch (SQLException e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		
		return courseList;
	}

}
